<?php
class UserHelper
{
	/**
	 * 找出数组键名为uid的值，取用户信息存到键名user内
	 */
	public static function patch(&$list, $single=false)
	{
		static $u = array();
		
		if($single)
		{
			if(isset($list['uid']))
			{
				$uid	=	$list['uid'];
				if(isset($u[$uid]))
				{
					$list['user']	=	$u[$uid];
				}
				else
				{
					$u[$uid] = $list[$uid] = User::get($uid);
				}
			}
		}
		else
		{
			foreach($list as &$user)
			{
				$uid	=	$user['uid'];
				if(isset($u[$uid]))
				{
					$user['user']	=	$u[$uid];
				}
				else
				{
					$u['user'] = $user['user'] = User::get($uid);
				}
			}
		}
		
		return $list;
	}

	
}
?>